package app.netant.finishbook.pinshuguan;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class PinshuguanDetail extends BaseDetail {

	public PinshuguanDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.pinshuguan.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".wrap .novel .contain .one .r.fr .title h2");
		if(parts.size()>0){
			String title = parts.get(0).text();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
		
		Elements parts2 = this.select(".wrap .novel .contain .one .r.fr .title span");
		if(parts2.size()>0){
			String writers = parts2.get(0).text();
			int idx = writers.indexOf("：");
			if(idx>0){
				writers = writers.substring(idx+1).trim();
			}
			System.out.println("【Writer】:"+writers);
			this.entity.setNovelWriter(writers);
		}
	}

	@Override
	public void analyseTags() {
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".wrap .novel .contain .one .r.fr .intro_con .introCon");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".wrap .novel .contain .one .l.fl .inputli a.wantElite");
		if(parts.size()>0){
			String href = parts.get(0).attr("href");
			if(href.startsWith("/")){
				href = this.preHref + href;
			}
			System.out.println("【Href】:"+href);
			this.entity.setDownPath(href);
		}
	}
	
	@Override
	public void analyseType() {
		Elements parts = this.select(".wrap .path .path_1 h2 a");
		if(parts.size()>1){
			String type = parts.get(1).text();
			System.out.println("【Type】:"+type);
			this.entity.setNovelType(type);
		}
	}
	
	public static void main(String[] args) {
		PinshuguanDetail detail = new PinshuguanDetail("http://www.pinshuguan.com/1885/");
		detail.test();
	}



}
